package day16.ZiXi.UDP.GuangBo;

import java.io.IOException;
import java.net.*;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //1. 创建发送端Socket对象(DatagramSocket)
        DatagramSocket ds = new DatagramSocket();
        //2. 创建存储数据的箱子,将广播地址封装进去
        String s = "老八秘制小汉堡";
        byte[] bytes = s.getBytes();
        InetAddress arr = InetAddress.getByName("255.255.255.255");
        int port = 10000;
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,arr,port);
        //3. 发送数据
        ds.send(dp);
        //4. 释放资源
        ds.close();
    }
}
